using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using GameEngine;

namespace GameFramework
{
    public class BoundingBox
    {
        private Vector2D topLeft = null;
        private Vector2D bottomRight = null;
        
        public BoundingBox()
        {
            topLeft = new Vector2D();
            bottomRight = new Vector2D();
        }

        public BoundingBox(Vector2D topLeft, Vector2D bottomRight)
        {
            this.topLeft = topLeft;
            this.bottomRight = bottomRight;
        }

        public Vector2D GetTopLeft()
        {
            return topLeft;
        }

        public Vector2D GetBottomRight()
        {
            return bottomRight;
        }

        public void Set(Vector2D topLeft, Vector2D bottomRight)
        {
            this.topLeft = topLeft;
            this.bottomRight = bottomRight;
        }

        public void Set(BoundingBox box)
        {
            topLeft.Set(box.topLeft.GetX(), box.topLeft.GetY());
            bottomRight.Set(box.bottomRight.GetX(), box.bottomRight.GetY());
        }

        public bool HasCollided(BoundingBox boundingBox)
        {
            if (boundingBox == null)
                return false;
            return (Rectangle.Intersect(new Rectangle((int)topLeft.GetX(), (int)topLeft.GetY(), (int)bottomRight.GetX() - (int)topLeft.GetX(), (int)bottomRight.GetY() - (int)topLeft.GetY()), new Rectangle((int)boundingBox.topLeft.GetX(), (int)boundingBox.topLeft.GetY(), (int)boundingBox.bottomRight.GetX() - (int)boundingBox.topLeft.GetX(), (int)boundingBox.bottomRight.GetY() - (int)boundingBox.topLeft.GetY())) != Rectangle.Empty);
        }

        
    }
}
